// pages/device/device.js
import {
  lgRequest
} from "../../utils/ajax";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    statusBarHeight: getApp().globalData.statusBarHeight,
    titleBarHeight: getApp().globalData.titleBarHeight,
    sysInfo:getApp().globalData.sysInfo,
    isIphoneX:getApp().globalData.isIphoneX,
    addImgBtn:'https://www.mingchuliangzao.com.cn:8632/profile/upload/2022/07/19/379acf3b32e468f581aca46e51b239a3.png',
    delectImg:'https://www.mingchuliangzao.com.cn:8632/profile/upload/2022/07/19/713a49f43240fae4d44090d92d7f9cf6.png',
    searchPng:'https://www.mingchuliangzao.com.cn:8632/profile/upload/2022/07/19/43588c7108a76e57456b3671a193c19b.png',
    delectImgTag:'https://www.mingchuliangzao.com.cn:8632/profile/upload/2022/07/19/713a49f43240fae4d44090d92d7f9cf6.png',
    contentList:[
      {},{}
    ],
    showPop:false,
    showPopChildren:false
  },
  deviceDetail(e){
    let deviceId = e.currentTarget.dataset.item.deviceId;
    let pamars = {
      deviceId
    }
    lgRequest('serverList',pamars,{
      doSuccess:(r)=>{
        this.setData({
          deviceDetail:r.data
        })
      }
    })
    this.setData({
      showPop:!this.data.showPop
    })
    
  },
  goBack(){
    wx.navigateBack({
      delta: 1
    })
  },
  toAddPage(){
    wx.navigateTo({
      url: '../minePage/addNewDevice/addNewDevice',
    })
  },
  getContentList(){
    lgRequest("tabDeviceList",{},{
      doSuccess:(r)=>{
        console.log(r,'这是设备信息维护');
        this.setData({
          contentList:r.data
        })
      }
    })
  },
  onClose(){
    this.setData({
      showPop:!this.data.showPop
    })
  },
  showPopChildren(e){
    console.log(e)
    let deviceCode = e.currentTarget.dataset.item.deviceCode;
    let params = {
      deviceCode
    } 
    lgRequest("serverList",params,{
      doSuccess:(r)=>{
        this.setData({
          deviceDetailItem: r.data[0],
          showPopChildren:true,
        })
        
      }
    })
  },
  closePopChidfren(){
    this.setData({
      showPopChildren:false,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getContentList();//获取设备信息
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})